import request from '@/utils/request'

/**
 * 获取一级分类数据
 * @returns
 */
export const reqCategory1List = () => {
  return request({
    url: '/admin/product/getCategory1',
    method: 'get'
  })
}

/**
 * 获取二级分类数据
 * @param {*} category1Id:一级分类id
 * @returns
 */
export const reqCategory2List = (category1Id) => {
  return request({
    url: `/admin/product/getCategory2/${category1Id}`,
    method: 'get'
  })
}

/**
 * 获取三级分类数据
 * @param {*} category2Id:二级分类id
 * @returns
 */
export const reqCategory3List = (category2Id) => {
  return request({
    url: `/admin/product/getCategory3/${category2Id}`,
    method: 'get'
  })
}

/**
 * 根据三级分类的三个id获取平台属性数据
 * @param {*} category1Id:一级分类id
 * @param {*} category2Id:二级分类id
 * @param {*} category3Id:三级分类id
 * @returns
 */
export const reqAttrList = (category1Id, category2Id, category3Id) => {
  return request({
    url: `/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`,
    method: 'get'
  })
}

/**
 * 添加属性与属性值
 * @param {*} data:属性数据
 * @returns
 */
export const reqAddOrUpdateAttr = (data) => {
  return request({
    url: '/admin/product/saveAttrInfo',
    method: 'post',
    data
  })
}
/*
{
  "attrName": "string",				属性名
  "attrValueList": [					属性值
    {
      "attrId": 0,						属性Id
      "id": 0,
      "valueName": "string"		属性值
    }
  ],
  "categoryId": 0,						cate3Id
  "categoryLevel": 0,					3
  "id": 0
}
*/

export const req = () => {
  return request({
    url: '',
    method: ''
  })
}
